package com.coding.kan_yi_dao.controller;


import com.coding.kan_yi_dao.common.Result;
import com.coding.kan_yi_dao.entity.User;
import com.coding.kan_yi_dao.service.impl.UserServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 砍一刀，不买就砍你一刀
 * @since 2023-09-20
 */
@Api(tags = "前台管理")
@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {
@Resource
    UserServiceImpl userService;

//TODO 前台登入
    @ApiOperation(value = "前台登入")
    @GetMapping("/gofront/login")
    public Result go_front_login(User user){
        return userService.go_front_login(user);
    }

    //TODO 前台注册
    @ApiOperation(value = "前台注册")
    @GetMapping("/go/register")
    public Result go_register(User user){
        return userService.go_register(user);
    }

    //TODO 修改密码
    @ApiOperation(value = "修改密码")
    @GetMapping("/goupdate")
    public Result go_update(Integer userId, String userPassword, String new_userPassword){
        return userService.go_update(userId,userPassword,new_userPassword);
    }
    //TODO 全查询
    @ApiOperation(value = "全查询")
    @GetMapping("/go_select/user")
    public Result go_select(User user){
        return userService.go_select( user);
    }
    //TODO 修改
    @ApiOperation(value = "锁定账户")
    @GetMapping("/go_update/users")
    public Result go_update(@RequestParam(value = "ids",required = false) List<Integer> ids){
        return userService.go_update(ids);
    }

    //TODO 修改
    @ApiOperation(value = "解除账户")
    @GetMapping("/go_update/user")
    public Result go_updates(@RequestParam(value = "ids",required = false) List<Integer> ids){
        return userService.go_updates(ids);
    }

    //TODO 修改
    @ApiOperation(value = "修改(前端调用用户修改)")
    @GetMapping("/go_updatess/userss")
    public Result go_updatess(User user){
        return userService.go_updatess(user);
    }
}
